home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group93c.txt
/
000006_icon-group-sender _Sun Jul 11 12:47:22 1993.msg
< prev
next >
Wrap
Internet Message Format
|
1994-02-02
|
2KB
Received: by cheltenham.cs.arizona.edu; Sun, 11 Jul 1993 10:14:14 MST
Date: Sun, 11 Jul 93 12:47:22 EDT
From: Paul_Abrahams@MTS.cc.Wayne.edu
To: icon-group@cs.arizona.edu
Message-Id: <699110@MTS.cc.Wayne.edu>
Subject: Sort enhancements for records and lists
Status: R
Errors-To: icon-group-errors@cs.arizona.edu
I'd like to revisit a question that I know has come up before: enhancing
the sort function to provide a useful treatment of records and lists.
First, a general observation: the current definition of record sorting is
that records are sorted in order of their creation times. Lists are
treated similarly. It's hard to imagine how that ordering can be put to
a useful purpose. Therefore it's reasonable to treat the ordering of
records and lists during sorting as being undefined and thus available
for redefinition. Defining an order (however that is done) is very
unlikely to invalidate any existing programs.
The obvious rule for sorting lists is that they are sorted by their first
element; within equal first elements, by their second element, and so
forth. This simple extension would provide multi-field sorting,
something that many people have requested.
Records can be sorted by the same rule, treating records (regardless of
their types) as lists of their components. Since there is no obvious
ordering among different record types, this treatment is as good as any;
sorting collections of records of diverse types is not particularly
useful.
Since &null already comes first in sort order, missing elements always
sort ahead of elements that were given explicitly without any special
provisions (for both records and lists).
It's worth noting that this multi-field sort does have its limitations.
In particular, it doesn't provide for sorting some fields in increasing
order and others in decreasing order. (If all fields are in decreasing
order, the desired result can be gotten by reversing the list produced by
sorting in increasing order.) This deficiency could be gotten round by
providing a fourth argument, a list of "+"s and "-"s, that specifies the
direction of sorting consecutive fields.
All this is modulo the standard observation that the Icon Project has
limited resources and implements only those enhancements that it
considers worth the expenditure of those resources.
Paul Abrahams
Reply-To: abrahams@acm.org